package cn.edu.hitwh.kanlema.config;

import cn.edu.hitwh.kanlema.interceptor.AuthInterceptor;
import cn.edu.hitwh.kanlema.interceptor.SignInterceptor;
import cn.edu.hitwh.kanlema.util.RedisCache;
import cn.edu.hitwh.kanlema.util.SignUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private RedisCache redisCache;

    @Autowired
    private SignUtil signUtil;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor(redisCache))
                .addPathPatterns("/**");

        registry.addInterceptor(new SignInterceptor(signUtil))
                .addPathPatterns("/**");
    }
}
